package com.lmk.mkcc.controller;

import com.lmk.mkcc.CourseDoc;
import com.lmk.mkcc.dto.CourseEsDto;
import com.lmk.mkcc.result.JSONResult;
import com.lmk.mkcc.result.PageList;
import com.lmk.mkcc.service.ISearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course")
@Slf4j
public class SearchController {
    @Autowired
    private ISearchService searchService;


    @PostMapping("/addCourseEs")
    public JSONResult saveCourseEs(@RequestBody CourseDoc courseDoc){
        searchService.add(courseDoc);
        return JSONResult.success();
    }

    @DeleteMapping("/delect/{id}")
    public JSONResult delectCourseEs(@PathVariable("id") Long id){
        searchService.delect(id);
        return JSONResult.success();
    }

    // es查询
    @PostMapping("/search")
    public JSONResult getCourseEs(@RequestBody CourseEsDto courseEsDto){
        PageList<CourseDoc> pageList = searchService.getCourseEs(courseEsDto);
        return JSONResult.success(pageList);
    }
}
